<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>

<%@taglib prefix="f" uri="http://java.sun.com/jsf/core"%>
<%@taglib prefix="h" uri="http://java.sun.com/jsf/html"%>

<jsp:include page="/WEB-INF/jspf/header.jsp">
    <jsp:param name="title" value="View Accounts" />
</jsp:include>

<f:view>
     <h:form >
    <%@include file="/WEB-INF/jspf/menu_customer.jspf" %>
   
        <h1><h:outputText value="View Accounts" /></h1>

        <h:dataTable value="#{account.accounts}" var="item" border="2" cellspacing="5" cellpadding="5">
            <h:column>
                <f:facet name="header">
                    <h:outputText value="Balance"/>
                </f:facet>
                <h:outputText value="#{item.balance}"/>
            </h:column>
            <h:column>
                <f:facet name="header">
                    <h:outputText value="Currency"/>
                </f:facet>
                <h:outputText value="#{item.currency}"/>
            </h:column>
            <h:column>
                <f:facet name="header">
                    <h:outputText value="Id"/>
                </f:facet>
                <h:outputText value="#{item.id}"/>
            </h:column>
            <h:column>
                <f:facet name="Transactions">
                    <h:outputText value="Transactions"/>
                </f:facet>
                <h:outputLink value="viewTransactions.jsp">
                    <f:param name="accountId" value="#{item.id}"/>
                    <h:outputText value="View Transactions"/>
                </h:outputLink>
            </h:column>
            <h:column>
                <f:facet name="Transfer Money">
                    <h:outputText value="Transfer Money"/>
                </f:facet>
                <h:outputLink value="transferMoney.jsp">
                    <f:param name="accountId" value="#{item.id}"/>
                    <h:outputText value="Transfer Money"/>
                </h:outputLink>
            </h:column>
        </h:dataTable>

        <h:outputText value="  Total balance:   "/>  <h:outputText value="#{account.totalBalance}   "/>
        <h:outputText value="   Currency:"/>
        <h:selectOneMenu id="colorType"  value="#{account.currency}" onchange="this.form.submit()"  valueChangeListener="#{account.processUpdate}">
            <f:converter converterId="CurrencyConverter" />
            <f:selectItems value="#{account.currencyChoices}" />
        </h:selectOneMenu>
        <h:message infoClass="info" errorClass="error" for="currency"/>

    </h:form>
    </body>
    </html>
</f:view>
